home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / vol_400 / 414_01 / comm3.c < prev    next >
C/C++ Source or Header  |  1993-11-15  |  35KB  |  1,216 lines

  1. /***********************************************************************/
  2. /* COMM3.C - Commands K-O                                              */
  3. /* This file contains all commands that can be assigned to function    */
  4. /* keys or typed on the command line.                                  */
  5. /***********************************************************************/
  6. /*
  7.  * THE - The Hessling Editor. A text editor similar to VM/CMS xedit.
  8.  * Copyright (C) 1991-1993 Mark Hessling
  9.  *
  10.  * This program is free software; you can redistribute it and/or
  11.  * modify it under the terms of the GNU General Public License as
  12.  * published by the Free Software Foundation; either version 2 of
  13.  * the License, or any later version.
  14.  *
  15.  * This program is distributed in the hope that it will be useful,
  16.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  18.  * General Public License for more details.
  19.  *
  20.  * You should have received a copy of the GNU General Public License
  21.  * along with this program; if not, write to:
  22.  *
  23.  *    The Free Software Foundation, Inc.
  24.  *    675 Mass Ave,
  25.  *    Cambridge, MA 02139 USA.
  26.  *
  27.  *
  28.  * If you make modifications to this software that you feel increases
  29.  * it usefulness for the rest of the community, please email the
  30.  * changes, enhancements, bug fixes as well as any and all ideas to me.
  31.  * This software is going to be maintained and enhanced as deemed
  32.  * necessary by the community.
  33.  *
  34.  * Mark Hessling                     email: M.Hessling@gu.edu.au
  35.  * 36 David Road                     Phone: +61 7 849 7731
  36.  * Holland Park                      Fax:   +61 7 875 5314
  37.  * QLD 4121
  38.  * Australia
  39.  */
  40.  
  41. /*
  42. $Header: C:\THE\RCS\comm3.c 1.4 1993/09/01 16:25:40 MH Interim MH $
  43. */
  44.  
  45. #include <stdio.h>
  46.  
  47. #include "the.h"
  48. #include "proto.h"
  49.  
  50. /*#define DEBUG 1*/
  51.  
  52. /*-------------------------- external data ----------------------------*/
  53. extern LINE *next_line,*curr_line;
  54. extern VIEW_DETAILS *vd_current,*vd_first,*vd_mark;
  55. extern char current_screen;
  56. extern SCREEN_DETAILS screen[MAX_SCREENS];        /* screen structures */
  57. extern char display_screens;                      /* number of screens */
  58. extern char current_file;         /* pointer to current file */
  59. extern WINDOW *foot,*error_window;
  60. extern bool error_on_screen;
  61. extern char *rec;
  62. extern unsigned short rec_len;
  63. extern char mode_insert;        /* defines insert mode toggle */
  64. extern char in_profile;    /* indicates if processing profile */
  65.  
  66. extern char *temp_cmd;
  67. extern char *last_target;
  68. /*man-start*********************************************************************
  69. COMMAND
  70.      left_arrow - move the cursor left one column
  71.  
  72. SYNTAX
  73.      ** effective only if bound to a key **
  74.  
  75. DESCRIPTION
  76.      The left_arrow command moves the cursor left one column in the
  77.      current window. Scrolling of the main window horizontally, occurs
  78.      if the cursor is at the left-most column and the left-most column
  79.      is not the first column of the line.
  80.  
  81. COMPATIBILITY
  82.      XEDIT: N/A
  83.      KEDIT: Equivalent of CURSOR LEFT
  84.  
  85. SEE ALSO
  86.      Right_arrow
  87.  
  88. STATUS
  89.      Complete.
  90. **man-end**********************************************************************/
  91. #ifdef PROTO
  92. int Left_arrow(char *params)
  93. #else
  94. int Left_arrow(params)
  95. char *params;
  96. #endif
  97. /***********************************************************************/
  98. {
  99. /*------------------------- external data -----------------------------*/
  100.  extern bool CMDARROWSTABLRx;
  101. /*--------------------------- local data ------------------------------*/
  102.  unsigned short x,y;
  103.  short col,old_col;
  104. /*--------------------------- processing ------------------------------*/
  105. #ifdef TRACE
  106.  trace_function("comm3.c:   Left_arrow");
  107. #endif
  108.  getyx(CURRENT_WINDOW,y,x);
  109. /*---------------------------------------------------------------------*/
  110. /* For all windows, if we are not at left column, move 1 pos to left.  */
  111. /*---------------------------------------------------------------------*/
  112.  if (x > 0)
  113.    {
  114.     wmove(CURRENT_WINDOW,y,x-1);
  115. #ifdef TRACE
  116.     trace_return();
  117. #endif
  118.     return(RC_OK);
  119.    }
  120. /*---------------------------------------------------------------------*/
  121. /* For all windows, determine if CMDARROWSTABLRx is set for tabbing or */
  122. /* scrolling and act accordingly.                                      */
  123. /*---------------------------------------------------------------------*/
  124.  switch(CURRENT_VIEW->current_window)
  125.    {
  126.     case WINDOW_MAIN:
  127.          if (CMDARROWSTABLRx)
  128.            {
  129.             if (CURRENT_VIEW->prefix)
  130.               {
  131.                Tabpre("");
  132.                wmove(CURRENT_WINDOW,y,getmaxx(CURRENT_WINDOW)-1);
  133.               }
  134.             else
  135.                wmove(CURRENT_WINDOW,y,getmaxx(CURRENT_WINDOW)-1);
  136.            }
  137.          else
  138.            {
  139.             if (CURRENT_VIEW->verify_start != CURRENT_VIEW->verify_col)
  140.               {
  141.                old_col = (CURRENT_VIEW->verify_col-1);
  142.                x = CURRENT_SCREEN.cols / 2;
  143.                col = max((short)CURRENT_VIEW->verify_start,
  144.                          (short)(CURRENT_VIEW->verify_col-1) - (short)x);
  145.                CURRENT_VIEW->verify_col = col;
  146.                show_page();
  147.                x = old_col - (CURRENT_VIEW->verify_col-1);
  148.                wmove(CURRENT_WINDOW,y,x-1);
  149.               }
  150.            }
  151.          break;
  152.     case WINDOW_PREFIX:
  153.          if (CMDARROWSTABLRx)
  154.             if (CURRENT_VIEW->prefix)
  155.               {
  156.                Tabpre("");
  157.                wmove(CURRENT_WINDOW,y,getmaxx(CURRENT_WINDOW)-1);
  158.               }
  159.          break;
  160.     case WINDOW_COMMAND:
  161.          if (CMDARROWSTABLRx)
  162.             wmove(CURRENT_WINDOW,y,getmaxx(CURRENT_WINDOW)-1);
  163.          break;
  164.     default:
  165.          break;
  166.    }
  167. #ifdef TRACE
  168.  trace_return();
  169. #endif
  170.  return(RC_OK);
  171. }
  172. /*man-start*********************************************************************
  173. COMMAND
  174.      locate - make line identified by target become the current line
  175.  
  176. SYNTAX
  177.      [Locate] target
  178.  
  179. DESCRIPTION
  180.      The LOCATE command looks for the next or previous occurrence of the
  181.      specified target.  If no parameter is supplied, LOCATE
  182.      searches for the string that was used as the last string target, if
  183.      such a string target exists.
  184.  
  185. COMPATIBILITY
  186.      XEDIT: Does not support [subcommand] option.
  187.      KEDIT: Compatible. (See bleow)
  188.      Does not support not,and,or combinations of string targets.
  189.      ie ~,& and | not supported.
  190.  
  191. STATUS
  192.      Complete.
  193. **man-end**********************************************************************/
  194. #ifdef PROTO
  195. int Locate(char *params)
  196. #else
  197. int Locate(params)
  198. char *params;
  199. #endif
  200. /***********************************************************************/
  201. {
  202. /*--------------------------- local data ------------------------------*/
  203.  unsigned short x,y;
  204.  short rc;
  205. /*--------------------------- processing ------------------------------*/
  206. #ifdef TRACE
  207.  trace_function("comm3.c:   Locate");
  208. #endif
  209. /*---------------------------------------------------------------------*/
  210. /* If no parameter is specified, use the last_target. If that doesn't  */
  211. /* exist, error.                                                       */
  212. /*---------------------------------------------------------------------*/
  213.  if (strcmp(params,"") == 0)
  214.    {
  215.     if (strcmp(last_target,"") == 0)
  216.       {
  217.        display_error(39,(char *)"");
  218. #ifdef TRACE
  219.        trace_return();
  220. #endif
  221.        return(RC_INVALID_OPERAND);
  222.       }
  223.     rc = command_line(last_target,COMMAND_ONLY_FALSE);
  224. #ifdef TRACE
  225.     trace_return();
  226. #endif
  227.     return(rc);
  228.    }
  229.  rc = command_line(params,COMMAND_ONLY_FALSE);
  230. #ifdef TRACE
  231.  trace_return();
  232. #endif
  233.  return(rc);
  234. }
  235. /*man-start*********************************************************************
  236. COMMAND
  237.      lowercase - change uppercase characters to lowercase
  238.  
  239. SYNTAX
  240.      LOWercase [target]
  241.  
  242. DESCRIPTION
  243.      The LOWERCASE command changes all uppercase characters in the target
  244.      to lowercase. All other characters remain untouched.
  245.  
  246. COMPATIBILITY
  247.      XEDIT: Equivalent of LOWERCAS command.
  248.      KEDIT: Compatible.
  249.  
  250. STATUS
  251.      Complete.
  252. **man-end**********************************************************************/
  253. #ifdef PROTO
  254. int Lowercase(char *params